<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml"
      xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>客户管理</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=39cd89cd">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style>
        table.text-center, table.text-center td, table.text-center th {
            text-align: center;
            font-size: 12px;
        }

        .lineF span {
            max-height: 140px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 7;
            text-align: left;
        }
        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }
        .moduleName {
            float: left;
            height: 27px;
            line-height: 27px;
            font-size: 22px;
            width: 100px;
            text-align: center;
        }

        .tryStyle {
            width: 30px;
            height: 14px;
            line-height: 14px;
            font-size: 12px;
            /* top: 0; */
            right: 0;
            position: absolute;
            border-radius: 5px;
            margin-top: 1px;
            background: red;
            color: #fff;
            margin-right: -2px;
            transform: scale(0.8);
        }

        .nav-tabs-custom {
            padding: 10px;
            margin-bottom: 0;
            box-shadow: none;
            position: relative;
            overflow: hidden;
        }

        .infoReport {
            display: flex;
            justify-content: flex-start;
            text-align: left;
            margin-left: 10px;
        }

        .infoReport div {
            margin: 0 10px;
        }

        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .lineOneNoMore {
            text-align: left;
        }

        .lineOneNoMore span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .mScrollBox {
            float: left;
            position: relative;
        }

        .imgStyle {
            width: 300px;
            height: 400px;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .templateStyle {
            border: 1px solid #ddd;
            margin-bottom: 10px;
            padding-bottom: 10px;
        }

        .table > thead > tr > th {
            padding: 0;
        }

        .table > tbody > tr > td {
            position: relative;
        }
        .table>tbody>tr>td{
            height: 30px;
            max-height: 28px;
            overflow: hidden;
        }

    </style>

</head>
<body>
<section class="content" id="app" v-cloak>
    <div class="div-td-content-more"><i></i></div>

    <!--客户-区域经理模块-->
    <div class="" v-if="isHasModule('customersPersonal')" id="scrollDiv">
        <div class="nav-tabs-custom oaReportNav">
            <!-- Tabs within a box -->
          <!--  <div class="moduleName"></div>-->
            <div style="height: 25px;margin-bottom: 10px;">
                <input type="text" placeholder="姓名/电话号码" class="form-control pull-left input-sm" style="width: 150px;position: absolute;left: 0px;"
                       v-model="key">
                <button type="button" class="btn oaBtn btn-sm pull-right"   style="margin-left: 10px;height: 27px;position: absolute;left: 160px;top: 8px;"
                        @click="get_customersPersonal">查询
                </button>
            </div>
            <button type="button" class="btn oaBtn btn-sm pull-right"
                    style="margin-left: 10px;height: 27px;position: absolute;right: 0px;top: 10px;"
                    @click="goDetail(0,'edit',1)">新增客户
            </button>

        </div>
        <div class="box-body no-padding iframeH2" style="overflow: auto;" id="customersPersonal">
            <div id="progress" class="wyui-progress"></div>
            <table class="table table-hover table-bordered text-center table-striped">
                <thead>
                <tr>
                    <th style="width: 40px;">序号</th>
                    <th style="width: 70px;">客户姓名</th>
                    <th style="width: 100px;">客户电话</th>
                    <th style="width: 100px;">客户类型</th>
                    <th style="width: 70px;">客户信用</th>
                    <th style="width: 100px;">客户所在地</th>
                    <th style="width: 70px;">购买时间</th>
                    <th style="width: 70px;">意向机型</th>
                    <th style="width: 70px;">购买方式</th>
                   <!-- <th style="width: 70px;">丢单状态</th>-->
                    <th style="width: 90px;">意向时间</th>
                    <th> 基本情况</th>
                </tr>
                </thead>
                <tbody>
                <template v-if="customer.list.length>0">
                    <tr v-for="(item,i) in customer.list">
                        <td>{{i+1}}</td>
                        <td  @click="goDetail(item.id,'edit',0)" ><span style="text-align:center;color:#169BD5;cursor: pointer; ">{{item.name}}</span></td>
                        <td>{{item.tel}}</td>
                        <td>{{item.customerType}}</td>
                        <td>{{item.customerCredit}}</td>
                        <td>{{item.cityName}}{{item.countyName}}</td>
                        <td>{{item.buyDate}}</td>
                        <td>{{item.intentionModel}}</td>
                        <td>{{item.buyType}}</td>
                        <!--<td>
                            <span v-if="item.intentionFlag==2">是</span>
                            <span v-else="item.intentionFlag==1">否</span>
                        </td>-->
                        <td>{{item.intentionTime}}</td>
                        <td class="lineOne"><span>{{item.otherCondition}}</span></td>
                    </tr>
                </template>
                <template v-else>
                    <tr>
                        <td colspan="12">暂无数据</td>
                    </tr>
                </template>
                </tbody>
            </table>
        </div>
        <div class="clearfix"></div>
    </div>
    <!--客户-大区经理模块-->
    <div class="" v-if="isHasModule('customersDepart')" id="scrollDivBig">
        <template v-if="roleName=='大区经理'">
            <div class="nav-tabs-custom oaReportNav">
                <!-- Tabs within a box -->
                <!--大区及其下属姓名-->
                <ul class="nav nav-tabs pull-right" style="margin-bottom: 10px;" v-cloak>
                    <li v-for="(item,i) in tab" @click="get_customersDepart(item.userId)" :class="i==0?'active':''">
                        <a href="#sales-chart" data-toggle="tab">{{item.name}}</a>
                    </li>
                </ul>
                <button type="button" class="btn oaBtn btn-sm pull-right"
                        style="margin-left: 10px;height: 27px;position: absolute;right: 10px;top: 10px;"
                        @click="goDetail(0,'edit',1)">新增客户
                </button>
            </div>
            <div style="height: 25px;margin-bottom: 10px;">
                <input type="text" placeholder="姓名/电话号码" class="form-control pull-left input-sm" style="width: 150px;position: relative;left: 10px;top:0px;"
                       v-model="key">
                <button type="button" class="btn oaBtn btn-sm pull-right"   style="margin-left: 10px;height: 27px;position: relative;right:1070px;top:-2px;"
                        @click="get_customersPersonal">查询
                </button>
            </div>
            <div style="padding: 0 10px;background: #fff;" id="customersDepartBig">
                <div style="width: 100%;" class="mScrollBox">
                    <table class="table table-hover table-bordered text-center table-striped">
                        <thead>
                        <tr>
                            <th style="width: 40px;">序号</th>
                            <th style="width: 70px;">客户姓名</th>
                            <th style="width: 100px;">客户电话</th>
                            <th style="width: 100px;">客户类型</th>
                            <th style="width: 70px;">客户信用</th>
                            <th style="width: 100px;">客户所在地</th>
                            <th style="width: 70px;">购买时间</th>
                            <th style="width: 70px;">意向机型</th>
                            <th style="width: 70px;">购买方式</th>
                          <!--  <th style="width: 70px;">丢单状态</th>-->
                            <th style="width: 90px;">意向时间</th>
                            <th> 基本情况</th>
                            <!-- <th style="width: 4%;">操作</th>-->
                        </tr>
                        </thead>
                        <tbody>
                        <template v-if="customer.list.length>0">
                            <tr v-for="(item,i) in customer.list">
                                <td>{{i+1}}</td>
                                <td  @click="goDetail(item.id,'edit',0)" ><span style="text-align:center;color:#169BD5;cursor: pointer; ">{{item.name}}</span></td>
                                <td>{{item.tel}}</td>
                                <td>{{item.customerType}}</td>
                                <td>{{item.customerCredit}}</td>
                                <td>{{item.cityName}}{{item.countyName}}</td>
                                <td>{{item.buyDate}}</td>
                                <td>{{item.intentionModel}}</td>
                                <td>{{item.buyType}}</td>
                               <!-- <td>
                                    <span v-if="item.intentionFlag==2">是</span>
                                    <span v-else="item.intentionFlag==1">否</span>
                                </td>-->
                                <td>{{item.intentionTime}}</td>
                                <td class="lineOne"><span>{{item.otherCondition}}</span></td>
                            </tr>
                        </template>
                        <template v-else>
                            <tr>
                                <td colspan="12">暂无数据</td>
                            </tr>
                        </template>
                        </tbody>
                    </table>
                </div>
                <div class="clearfix"></div>
            </div>
        </template>
        <!--区域支持等其他部门级别-->
        <template v-else>
            <div style="padding: 0 10px;background: #fff;" id="customersDepart">
                <div style="width: 100%;" class="mScrollBox">
                    <table class="table table-bordered text-center table-width">
                        <thead>
                        <tr>
                            <!--<th style="width: 5%;">序号</th>-->
                            <th style="width: 8%">部门/大区</th>
                            <th style="width: 8%;">岗位</th>
                            <th style="width: 8%;">姓名</th>
                            <th style="width: 8%;">客户总数</th>
                            <th style="width: 68%;">区域</th>
                        </tr>
                        </thead>
                        <tbody>
                        <template v-if="customer.list.length>0">
                            <tr v-for="(item,i) in customer.list">
                                <!--<td>{{i+1}}</td>-->
                                <td :rowspan="item.departNamespan" :class="{hidden: item.departNamedis}">
                                    {{item.departName}}
                                </td>
                                <td>{{item.roleName}}</td>
                                <td>
                                    {{item.userName}}
                                </td>
                                <template v-if="isCheck(item)&&item.num!=0&&item.num!='-'">
                                    <td style="color:#169BD5;cursor: pointer;" @click="openCustomerList(item.userId,true)">
                                        {{item.num}}
                                    </td>
                                </template>
                                <template v-else>
                                    <td>{{item.num}}</td>
                                </template>
                                <td class="lineOne">
                                    <span>{{item.regionName}}</span>
                                </td>
                            </tr>
                            <tr>
                                <td>合计</td>
                                <td></td>
                                <td></td>
                                <td>{{customer.numCount}}</td>
                                <td></td>
                            </tr>
                        </template>
                        <template v-else>
                            <tr>
                                <td colspan="5">暂无数据~</td>
                            </tr>
                        </template>
                        </tbody>
                    </table>
                </div>
                <div class="clearfix"></div>
            </div>
        </template>
    </div>
    <!--分页-->
    <div v-if="frontFlag==1">
        <div class="oa-pager text-center" style="margin-top: 5px;" >
            共
            <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
            <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
            <span class="oa-pager-button" id="first">首页</span>
            <span class="oa-pager-button" id="prev">上一页</span>
            <span class="oa-pager-button" id="next">下一页</span>
            <span class="oa-pager-button" id="last">尾页</span>
        </div>
    </div>
    <!--客户-公司级别模块-->
    <div class="" v-if="isHasModule('customersCompany')">
        <div style="padding: 0 10px;background: #fff;" id="customersCompany">
            <div style="width:100%;" class="mScrollBox">
                <table class="table table-bordered text-center table-width">
                    <thead>
                    <tr>
                        <!--<th style="width:5%">序号</th>-->
                        <th style="width: 10%">部门/大区</th>
                        <th style="width: 10%">岗位</th>
                        <th style="width: 8%">姓名</th>
                        <th style="width: 8%">客户总数</th>
                        <th style="width: 59%">区域</th>
                    </tr>
                    </thead>
                    <tbody>
                    <template v-if="customer.list.length>0">
                        <tr v-for="(item,i) in customer.list">
                            <!--<td>{{i+1}}</td>-->
                            <td :rowspan="item.departNamespan" :class="{hidden: item.departNamedis}">
                                {{item.departName}}
                            </td>
                            <td :rowspan="item.roleNamespan" :class="{hidden: item.roleNamedis}">{{item.roleName}}</td>
                            <td>
                                {{item.userName}}
                            </td>
                            <td v-if="item.num==''||item.num=='-'">-</td>
                            <td v-else @click="openCustomerList(item.userId,true)"
                                style="color:#169BD5;cursor: pointer;">
                                {{item.num}}
                            </td>
                            <td class="lineOne">
                                <span>{{item.regionName}}</span>
                            </td>
                        </tr>
                        <tr>
                            <td>合计</td>
                            <td></td>
                            <td></td>
                            <td>{{customer.numCount}}</td>
                            <td></td>

                        </tr>
                    </template>
                    <template v-else>
                        <tr>
                            <td colspan="5">暂无数据~</td>
                        </tr>
                    </template>
                    </tbody>
                </table>
            </div>
            <div class="clearfix"></div>
        </div>
    </div>
    <!--客户-集团级别模块-->
    <div class="" v-if="isHasModule('customersGroup')">
        <div style="padding: 0 10px;background: #fff;" id="customersGroup">
            <div class="mScrollBox" style="width:100%;">
                <table class="table table-bordered text-center table-width">
                    <thead>
                    <tr>
                        <!--<th style="width:5%;">序号</th>-->
                        <th style="width:57%">公司名称</th>
                      <!--  <th style="width:19%">新增客户</th>-->
                        <th style="width:19%">客户总数</th>
                    </tr>
                    </thead>
                    <tbody>
                    <template v-if="customer.list.length>0">
                        <tr v-for="(item,i) in customer.list">
                            <!--<td>{{i+1}}</td>-->
                            <td>{{item.companyName}}</td>
                           <!-- <td v-if="item.num==''||item.num=='-'">-</td>
                            <td v-else @click="openCustomersDepart(item.companyId,true)"
                                style="color:#169BD5;cursor: pointer;">{{item.num}}
                            </td>-->
                            <td v-if="item.allNum==''||item.allNum=='-'">-</td>
                            <td v-else @click="opencustomersDepart(item.companyId,false)"
                                style="color:#169BD5;cursor: pointer;">{{item.allNum}}
                            </td>
                        </tr>
                        <tr>
                            <td>合计</td>
                        <!--    <td>{{customer.numCount}}</td>-->
                            <td>{{customer.allNumCount}}</td>
                        </tr>
                    </template>
                    <template v-else>
                        <tr>
                            <td colspan="3"></td>
                        </tr>
                    </template>
                    </tbody>
                </table>
            </div>
            <div class="clearfix"></div>
        </div>
    </div>
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=558d0414"></script>

<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script src="/dist/plugins/select2/select2.full.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script>
    $.ajaxSetup({
        global: true,
        type: "POST",
        cache: false,
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        beforeSend: function () {
        },
        complete: function () {

        },
        error: function (e) {
            alert('error' + e.responseText);
        }
    });
    $.extend($.wyui, {
        postMethod: function (url, data, callback, sync, id) {
            if (!id) {
                id = "#app"
            }
            $.ajax({
                url: server.ip + url,
                async: sync ? false : true,
                data: JSON.stringify(data),
                beforeSend: function () {
                    App.blockUI({
                        target: id,
                        boxed: true,
                        message: '加载中......'//,
                        // animate: true
                    });
                },
                complete: function () {
                    setTimeout(function () {
                        App.unblockUI(id);
                    }, 1000);

                },
                success: function (r) {
                    if (!r.e.code) {
                        callback(r.data.sendData);
                    } else {
                        alert(r.e.desc);
                    }
                },
                error: function (e) {
                    console.log(url + e.responseText);
                    App.unblockUI('#app');
                }
            });
        },
    });
</script>
<script type="text/javascript">
    function refresh() {
        //3.通过拥有的模块调用各模块对应的接口
        app.getFunctionByTemplate();
        /*app.getRegionByUserId();*/
        /*  app.getRegionNameByUserId();*/
    }
    $(function () {
        $("body").on("click", ".lineOne,.lineTwo,.lineF", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });

    var app = new Vue({
        el: '#app',
        data: {
            userId: getCurrentUser().id,
            roleName:getCurrentUser().roleName,
            companyId: getCurrentUser().companyId,
            frontFlag: getCurrentUser().frontFlag,
            departId: getCurrentUser().departId,
            modules: [],//该人员拥有的模块列表,
            reginIds: [],//该人员拥有的区域列表ID
            regionNames: [],//该人员拥有的区域列表名称
            yesterday: new Date(new Date() - 24 * 60 * 60 * 1000).Format("yyyy-MM-dd"),
            today: new Date().Format("yyyy-MM-dd"),//今天
            hour: new Date().getHours(),
            thisMonth: new Date().Format("yyyy-MM"),
            thisWeek: new Date().Format("yyyy-MM-dd") + "-w",
            tab: [],
            list: [],
            key:'',
            customer: {
                id: '',
                name: '',
                tel: '',
                wechat: '',
                birthday: '',
                idCard: '',
                provinceName: '',
                cityName: '',
                countyName: '',
                source: '',
                intentionModel: '',
                buyType: '',
                fundCondition: '',
                existingDevice: '',
                OtherCondition: '',
                time: new Date().Format("yyyy-MM-dd"),
                list: [],
                weekNumCount:'',
                monNumCount:'',
                moreNumCount:'',
                allNumCount:'',
                customerName:'',
                throwFlag:'',
                throwReason:'',
                intentionFlag:''
            },
        },

        methods: {
            goDetail:function (customerId,pageType,isAdd) {
                var that=this;
                var H = $(window).height()-50;
                if (isAdd==1){
                    customerId="0";
                    that.userId= getCurrentUser().id;
                }else {
                    if ( !((that.userId)==(getCurrentUser().id)) ){
                        pageType='look';
                    }
                }

                $.dialog({
                    content: 'url:detail.html?pageType='+pageType+"&customerId="+customerId+"&userId="+getCurrentUser().id+"&isAdd="+isAdd,
                    title: '客户详情',
                    width: 400,
                    height: H,
                    max: true,
                    min: true,
                    lock: true
                });
            },

            //打开客户列表
            openCustomerList: function (userId, type) {
                var that = this;
                var isAll = true;
                if (type) {
                    isAll = false;
                }
                if (!userId) {
                    userId = this.userId
                }
                top.closeTabByPageId("khList2");
                top.addTabs({
                    id: 'khList2',
                    title: '客户列表',
                    close: true,
                    url: 'mineCustomerManagement/customerList.html?userId=' + userId + '&isAll=' + isAll
                });
            },
            //打开公司客户列表
            opencustomersDepart: function (companyId, type) {
                var that = this;
                if (!companyId) {
                    companyId = this.companyId
                }
                var that = this;
                top.closeTabByPageId("opencustomersDepart");
                top.addTabs({
                    id: 'opencustomersDepart',
                    title: '客户管理',
                    close: true,
                    url: 'mineCustomerManagement/customerDepart.html?companyId=' + companyId
                });
            },
            /*根据公司ID获得客户列表*/
            openCustomersListByCompanyId: function (companyId, type) {
                var that = this;
                var time = '';
                var isAll = true;
                if (type) {
                    time = that.customer.time;
                    isAll = false;
                }
                if (!companyId) {
                    companyId = this.companyId
                }
                var that = this;
                top.closeTabByPageId("khList2");
                top.addTabs({
                    id: 'khList2',
                    title: '客户列表',
                    close: true,
                    url: 'customerManagement/customerDepart.html?companyId=' + companyId
                });

            },


            trustTrialFlag2Name:function (flage) {
                if (flage == 1){return "已通过";}
                else if (flage == 2) {return "已驳回";}
                else if (flage == 0) {return "待审核";}
                else{return "-";}
            },
            showABtn: function (item, btnName) {
                switch (btnName) {
                    case 'browser':
                        switch (item.auditFlag) {
                            case -1:
                                return false;
                                break;
                            case 0:
                                return currentUser.id != item.currentAuditorId;
                                break;
                            case 1:
                            case 2:
                                return true;
                                break;
                        }
                        return true;
                        break;
                    case 'edit':
                        return item.auditFlag == -1 && item.createUserId == currentUser.id;
                        break;
                    case 'audit':
                        return item.auditFlag == 0 && currentUser.id == item.currentAuditorId;
                        break;
                    default:
                        break;
                }
            },
            showBtn: function (btnName) {
                switch (btnName) {
                    case "submitPay":
                        return this.pageType == 'pay' && ($.inArray('submitPay', this.rightOpENames) > -1);
                        break;
                    case "addApply":
                        return this.pageType == 'apply';
                        break;
                    case "payAudit":
                        if (this.pageType == 'apply') {
                            return false;
                        }
                        var result = false;
                        for (var i = 0; i < this.list.length; i++) {
                            if (this.list[i].currentAuditorId == getCurrentUser().id) {
                                result = true;
                                break;
                            }
                        }
                        return result;
                        break;
                    default:
                        break;
                }
            },

            isHasModule: function (moduleEName) {
                return $.inArray(moduleEName, this.modules) > -1;
            },
            //获取客户报表
            get_customersPersonal: function () {
                var that = this;
                $.wyui.page.dataUrl = server.ip + urlConfig.report.customerReport.getForPersonalCustomerList;
                $.wyui.page.queryParams.requestPage=1;
                $.extend($.wyui.page.queryParams, {userId: that.userId, key: that.key});
                $.wyui.page.getByPage()
                $.wyui.page.getByPage_callback = function (records) {
                    console.log(records)
                    app.customer.list = records;
                  //  document.getElementById("scrollDiv").scrollTop = 0;
                };
                $.wyui.page.getByPage_scroll_callback = function (list) {
                    if (list.length < 30) {
                        isLoad = false;
                    } else {
                        for (var i = 0; i < list.length; i++) {
                            app.customer.list.push(list[i]);
                        }
                        isLoad = true;
                        // }
                    };
                }
            },

            //获取大区客户报表
            get_customersDepart: function (id) {
                var that = this;
                if (that.roleName=='大区经理'){
                    if(!id){
                        id= that.userId;
                        $.wyui.postMethod( urlConfig.report.intentCustomer.getForUserInfo, {
                            "userId": id
                        }, function (data) {
                            console.log(data);
                            var data = trimRN2(data);
                            that.tab = data.records;
                        }, false, "#customersDepart");

                    }else {
                        that.userId=id;
                    }
                    $.wyui.page.dataUrl = server.ip + urlConfig.report.customerReport.getForPersonalCustomerList;
                    $.wyui.page.queryParams.requestPage=1;
                    $.extend($.wyui.page.queryParams, {userId: that.userId, key: that.key});
                    $.wyui.page.getByPage()
                    $.wyui.page.getByPage_callback = function (records) {
                        console.log(records)
                        app.customer.list = records;
                      //  document.getElementById("scrollDivBig").scrollTop = 0;
                    };
                    $.wyui.page.getByPage_scroll_callback = function (list) {
                        if (list.length < 30) {
                            isLoad = false;
                        } else {
                            for (var i = 0; i < list.length; i++) {
                                app.customer.list.push(list[i]);
                            }
                            isLoad = true;
                            // }
                        };
                    }
                }else {
                    var that = this;
                    $.wyui.postMethod(urlConfig.report.customerReport.getForDepartCustomerList, {
                        "userId": that.userId
                    }, function (data) {
                        console.log(data);
                        var data = trimRN2(data);
                        that.customer.list = that.tablesMergeCell(data.records);
                        that.customer.numCount = that.getCount(that.customer.list, "num");
                    }, false, "#customersDepart");
                }


            },
            //获取公司客户报表
            get_customersCompany: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.customerReport.getForCompanyCustomerList, {
                    "userId": that.userId
                }, function (data) {
                    console.log(data);
                    var data = trimRN2(data);
                    that.customer.list = data.records;
                    that.customer.numCount = that.getCount(that.customer.list, "num");
                }, false, "#customersCompany");
            },
            //获取集团客户报表
            get_customersGroup: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.customerReport.getForGroupCustomerList, {
                    "userId": that.userId
                }, function (data) {
                    console.log(data)
                    var data = trimRN2(data);
                    that.customer.list = data.records;
                    that.customer.numCount = that.getCount(that.customer.list, "num");
                    that.customer.allNumCount = that.getCount(that.customer.list, "allNum");
                }, false, "#customersGroup");
            },
            //获取modules
            getModules: function () {
                var that = this;
                $.wyui.postMethod( urlConfig.report.config.module.getModuleENamesByUserId, {userId: getCurrentUser().id}, function (data) {
                    var eNames = [];
                    for (var i = 0; i < data.length; i++) {
                        if(data[i].appTodayReport=='0'){
                            eNames.push(data[i].eName);
                        }
                    }
                    that.modules = eNames;
                    console.log(that.modules)
                }, true);
            },
            //通过拥有的模块调用各模块对应的接口
            getFunctionByTemplate: function () {
                var that = this;
                for (var i = 0; i < that.modules.length; i++) {
                    /* if (that.modules[i] == "signInPersonal") {
                     //大区经理-考勤和区域经理考勤初始时间不一样。所以特定调整一下；
                     that.sign.time = that.thisMonth;
                     }*/
                    console.log(that.modules[i])
                    if (that["get_" + that.modules[i]]) {
                        if (that.modules[i] == 'costDepart') {
                            that.get_costPersonal()
                        } else {
                            that["get_" + that.modules[i]]();

                        }
                    }

                }
            },
            getRegionByUserId: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.visitCustomer.getRegionByUserId, {userId: getCurrentUser().id}, function (ids) {
                    for (var i = 0; i < ids.length; i++) {
                        that.reginIds.push(ids[i].regionId);
                    }
//                    console.log(that.reginIds)
                }, true);
            },

            //合并单元格
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '') {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            },
            //获取合计
            getCount: function (arr, key) {
                var number = 0;
                for (var i = arr.length - 1; i >= 0; i--) {
                    number += (arr[i][key] && arr[i][key] != '-' ? arr[i][key] : 0)

                }
                return number;
            },
            isCheck: function (item) {
                var that = this;
                if (that.isHasRightOp(item.regionId)) {
                    return true
                }  else if (item.regionId==''){
                    return true;
                }
                else {
                    return false
                }
            },
            isHasRightOp: function (regionId) {
                //console.log($.inArray(regionId, this.reginIds) > -1)
                return $.inArray(regionId, this.reginIds) > -1;
            },
        },
        mounted: function () {

            console.log(getCurrentUser().roleName);
            var that = this;
            /* //1.获取前5个月的tab数据
             this.getTab();*/
            //2.获取该人员对应的模块
            this.getModules();
            //3.通过拥有的模块调用各模块对应的接口
            this.getFunctionByTemplate();
            this.getRegionByUserId();
            /* this.getRegionNameByUserId();*/
        }
    });


</script>
<script>
    /************************滚动加载******************************/
   /* var divscroll = document.getElementById('scrollDiv');*/

    function divScroll() {
        var wholeHeight = divscroll.scrollHeight;
        var scrollTop = divscroll.scrollTop;
        var divHeight = divscroll.clientHeight;
        console.log(scrollTop + divHeight, wholeHeight)
        if (scrollTop + divHeight >= wholeHeight - 2) {
//            alert('滚动到底部了！');
            if (isLoad) {
                isLoad = false;
                setTimeout($.wyui.page.getByPage("scroll"), 1000);
            }
            //这里写动态加载的逻辑，比如Ajax请求后端返回下一个页面的内容
        }

    }
    /*divscroll.onscroll = divScroll;*/
</script>
</body>
</html>